package com.zs.studentmanager.common;

import lombok.Data;

/**
 * @author: 周小白
 * @date: 2023-11-25 13:35
 * @description: 返回结果
 **/
@Data
public class Result {
    private Integer code;
    private String message;
    private Object data;

    public static Result success(){
        Result result = new Result();
        result.setCode(200);
        result.setMessage("success");
        return result;
    }

    public static Result success(Object data){
        Result result = new Result();
        result.setCode(200);
        result.setMessage("success");
        result.setData(data);
        return result;
    }

    public static Result fail(String msg){
        Result result = new Result();
        result.setCode(500);
        result.setMessage(msg);
        return result;
    }

    public static Result fail(ResponseCodeEnum responseCodeEnum){
        Result result = new Result();
        result.setCode(responseCodeEnum.getCode());
        result.setMessage(responseCodeEnum.getMessage());
        return result;
    }
}
